﻿using Adnc.Application.Shared;
using Adnc.WebApi.Shared;
using Microsoft.AspNetCore.Mvc;
using WYT.Ord.Application.Contracts.Dtos.Coupon;
using WYT.Ord.Application.Contracts.Services;

namespace WYT.Ord.WebApi.Controllers
{
    /// <summary>
    /// 优惠券
    /// </summary>
    [Route("ord/[Controller]")]
    [ApiController]
    public class CouponController : AdncControllerBase
    {
        private readonly ICouponAppService _couponAppService;

        private readonly IUserContext _userContext;

        public CouponController(ICouponAppService couponAppService
            , IUserContext userContext)
        {
            _couponAppService = couponAppService;
            _userContext = userContext;
        }

        /// <summary>
        /// 获取用户当前有效的优惠券
        /// </summary>
        /// <returns></returns>
        [HttpGet("list")]
        public async Task<WYTActionResult<List<CouponDto>>> GetCouponAsync()
        {
            return Success(await _couponAppService.GetCouponAsync(_userContext.Id));
        }
        /// <summary>
        /// 体验装兑换券兑换信息
        /// </summary>
        /// <returns></returns>
        [HttpGet("deductionCouponInfor")]
        public async Task<WYTActionResult<UserDeductionCouponDto>> GetUserDeductionCouponInfor()
            => Success(await _couponAppService.GetUserDeductionCouponInfor(_userContext.Id));

    }
}
